export const changeRouteList = (list) => {
  let res = [...list];
  let newArr = []
  try {
    res.forEach((item, index) => {
      if (index === res.length - 1) {
        let arr = splitList(item);
        newArr = [...newArr, ...arr]
      } else {
        if (item.components) {
          newArr.push(item)
        }
      }
    })
  } catch (error) {
    newArr = '请填写正确的路由格式!'
  }
  return newArr
}

const splitList = (route) => {
  console.log(111, route);
  if (route.name.indexOf('/') === -1) {
    let notChild = [
      { name: route.name, path: route.path },
      // { name: name[1], path: `/${path[1]}/${path[2]}` },
    ]
    return notChild
  }
  let obj = { ...route }
  let name = obj.name.split('/');
  let path = obj.path.split('/');
  let arr = [
    { name: name[0], path: `/${path[1]}` },
    { name: name[1], path: `/${path[1]}/${path[2]}` },
  ]
  return arr;
}